package controller

import (
	"encoding/json"
	"fmt"
	"gugojudger/env"
	"gugojudger/utils/ojchannel"
	"gugojudger/utils/ojresult"
	"net/http"
	"runtime"
)

func handleInfo(resp http.ResponseWriter, req *http.Request) {
	var res = ojresult.NewResult()
	res.SetMessage(200, true)
	res.AddData("OS", runtime.GOOS)
	res.AddData("ARCH", runtime.GOARCH)
	res.AddData("PROCESSOR", fmt.Sprintf("%d",runtime.GOMAXPROCS(0)))
	res.AddData("CPUNUM", fmt.Sprintf("%d",runtime.NumCPU()))
	res.AddData("GGJ_V", fmt.Sprintf("%s", env.GoguJudgerVersion))

	superChan.C <- ojchannel.FastLog(1, "GOT SYSTEM INFORMATION")
	resp.Header().Set("content-type","application/json")
	resJson, _ := json.Marshal(res)
	resp.Write(resJson)
}
